package com.medical.data.controller;

import com.medical.data.bean.ResultBean;
import com.medical.data.service.PushService;
import com.medical.data.service.TokenSerivce;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/gpt/xfModel")
@Api(description = "AIGC智能医嘱")
public class XFMessageController {
    @Autowired
    private PushService pushService;

    @Autowired
    private TokenSerivce tokenSerivce;

    @GetMapping("/text")
    @ApiOperation("访问gpt接口")
    public ResultBean text(@RequestParam String text) {
        String uid = tokenSerivce.getUser().getId();
        log.info("/gpt/xfModel/uid参数========>{}", uid,text);
        if (StringUtils.isEmpty(uid) || StringUtils.isEmpty(text)) {
            log.error("uid或text不能为空");
            return ResultBean.fail("uid或text不能为空");
        }
        return pushService.pushMessageToXFServer(uid, text);
    }
}

